import { Injectable } from '@angular/core';
import * as gc from 'src/app/global/globalconst';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { FollowInfo, JsonResult } from '../global/models';

@Injectable({
  providedIn: 'root'
})
export class AuditService {

  url = {
    'enterpriseCloud':gc.server + '/user/enterprisecloud',
    'clientCloud':gc.server + '/user/clientcloud',
  }

  constructor(
    private http:HttpClient
  ) { }

  setEnterpriseCloud(code:string,info:FollowInfo):Observable<JsonResult>{
    const url:string= this.url.enterpriseCloud + '/' + code + '/' + info.mill + '/' + info.clientId + '/' 
      + info.clientSid + '/' + info.clientName + '/' + info.openId + '/' + info.nickName + '/' + info.realName;
      console.log('请求企业云权限的连接是：' + url);
    return this.http.get<JsonResult>(url);
  }

  setClientCloud(code:string,info:FollowInfo):Observable<JsonResult>{
    const url:string= this.url.clientCloud + '/' + code + '/' + info.mill + '/' + info.clientId + '/' 
      + info.clientSid + '/' + info.clientName + '/' + info.openId + '/' + info.nickName + '/' + info.realName;
      console.log('请求客户云权限的连接是：' + url);
    return this.http.get<JsonResult>(url);
  }
}
